|Tools| <Button demo | |Up to Language Overview | |Lexical binding>

Language Overview Simple functions in yassl


5.2.2 Simple functions in yassl

Unlike Java, yassl is not object oriented. Unlike Java, yassl makes method as types that can be passed around, which can make some of the awt programming a little more intuitive.

This example creates yet another button, and attaches a procedure to it. This is the yassl script that does this task.

proc void pushed()
{
  ButtonLabel(b, 'Owww..');
  Enable(b, false);
}

Button b = new Button;
ButtonLabel(b, 'Press me');
SetAction(b, pushed);
Add(thisApplet, b);
Procedures are created with the proc keyword. SetAction is a general function that takes a widget and attaches a method to it. The method is called when any action occurs in the widget. The function Add is another general function that adds a widget to a container. The special variable thisApplet is available when the interpreter is invoked as an Applet. It is the applet itself, which permits new widgets to be added into the applet. Labels of buttons are set with ButtonLabel, which takes a Button and a String as arguments. Finally, any widget can be enabled or disabled with the general purpose Enable procedure.
|Tools| <Button demo | |Up to Language Overview | |Lexical binding>

KB Sriram
Comments, bug reports: kbs@sbktech.org

Revised: Sat May 25 02:58:13 1996
URL: http://www.sbktech.org/yas_butcb.html